var ns, UIAlbumBrowser, bmLocation;
app = new Vue({
    el: '#app',
    data: {
        ID:0,
        list: [],
        form: {
            RelationName:'',
            RelatePhoneNumber:'',
        },
        Balance:'',
        Explain:'',
        can_scroll:false,
        IsRoomOpen:false,
    },
    methods: {
        // get_data: function () {
        //     var that = this;
        //     var options = {};
        //     options.action = "getscanservicecard";
        //     options.ID = that.ID;
        //     ns.post(options, function (succeed, data, err) {
        //         console.log(JSON.stringify(options));
        //         console.log(JSON.stringify(err));
        //         console.log(JSON.stringify(data));
        //         if (succeed) {
        //                 that.form = data.data;
        //                 that.form.RelationName=(data.data.RelationName).toString();
        //                 that.form.RelatePhoneNumber=(data.data.RelatePhoneNumber).toString();
        //         } else if (err) {
        //             api.toast({
        //                 msg: err,
        //                 duration: 2000,
        //                 location: 'bottom'
        //             });
        //         }
        //     });
        // },
        do_save:function(){
            var that=this;
            that.IsRoomOpen=true;
        },
        doCloseRoom:function(){
            var that=this;
            that.IsRoomOpen=false;
        },
        do_suresave:function(){
            var that=this;
            var options = {};
            options.action = "savecollection";
            options.ID = that.form.ID;
            options.OwnerID = that.form.OwnerID;
            options.Balance = that.Balance;
            options.Explain = that.Explain;
            ns.post(options, function (succeed, data, err) {
                if (succeed) {
                    that.do_send(data.ID);
                    api.toast({
                        msg: '提交成功',
                        duration: 2000,
                        location: 'bottom'
                    });
                    api.sendEvent({
                        name: 'home_new_updata',
                    });
                    setTimeout(function() {
                        api.closeWin();
                    }, 500)
                } else if (err) {
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            }, {
                toast: true
            });
        },
        //给微信端发送消息通过的通知
        do_send: function (id) {
            var that = this;
            var message = "扫码已通过刷新列表";
            //发送消息
            webSocket.sendSocketMessage({
                msg: {
                    messageType: 2,
                    guid: 'fwkwx' + that.form.OwnerID,
                    content: id
                },
                success: function (res) {
                    webSocket.closeSocket();
                }
            })
        },

    }
});
apiready = function () {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.form = api.pageParam.item || '';
    app.form.RelationName=(app.form.RelationName).toString();
    app.form.RelatePhoneNumber=(app.form.RelatePhoneNumber).toString();
    webSocket.guid = 'fwkapp' + app.form.OwnerID;
    webSocket.closeSocket();
    setTimeout(function () {
        webSocket.connectSocket();
    }, 300)
};
